package com.oe.ldm.controller;

import com.oe.ldm.pojo.Article;
import com.oe.ldm.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.persistence.criteria.CriteriaBuilder;
import java.util.Map;

@Controller
public class IndexController {

    @Autowired
    ArticleService articleService;

    @RequestMapping("/index")
    public String page(Integer pageNo, Model model){
        int pageSize=3;
        if (pageNo==null||pageNo<=0){
            pageNo=0;
        }
        Page<Article> articles = articleService.queryPage(pageNo, pageSize);
        model.addAttribute("pageList",articles);
        return "index";
    }

}
